/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.core.service;

import com.intelligent.ispc.core.dto.CredentialsUserDto;
import com.intelligent.ispc.core.dto.ProjectDto;

import java.util.List;

/**
 * Created by Peter.Li on 2015/10/8.
 */
public interface SecurityService {

    public static final String HASH_ALGORITHM = "SHA-1";
    public static final int HASH_INTERATIONS = 1024;
    public static final int SALT_SIZE = 8;

    /**
     * Find user by login name.
     *
     * @param name
     * @return the user dto
     */
    CredentialsUserDto findByLoginName(String name);

    /**
     * Get the user in cache refreshed.
     * @param name
     * @return
     */
    CredentialsUserDto findRefreshUser(String name);

    /**
     * To authenticate the user by name and password.
     *
     * @param name
     * @param password
     * @return true if authenticated success
     */
    boolean authentication(String name, String password);


    /**
     * To update the user login info.
     * @param name
     * @param password
     * @return
     */
    CredentialsUserDto login(String name, String password);

    /**
     * update last login time.
     * @param name
     * @return
     */
    CredentialsUserDto refreshLoginTime(String name);

    /**
     * Get the current logged user's name.
     *
     * @return the login name of current user
     */
    String getCurrentUserLoginName();


    /**
     * Get the current logged user.
     *
     * @return the current user dto.
     */
    CredentialsUserDto getCurrentUser();

    List<ProjectDto> findDataPermissionForUser(String userId);
}
